//
//  ZCHomeModel.swift
//  weibo
//
//  Created by 张城 on 16/7/23.
//  Copyright © 2016年 张城. All rights reserved.
//

import UIKit

class ZCHomeModel: NSObject {

    var created_at: String?
    
    var id: Int64 = 0
    var text: String?
    
    var source: String?
    
    
    var user: ZCUser?
    
    var retweeted_status: ZCHomeModel?
    
    var pic_urls: [ZCPicturesModel]?
    
    
    var reposts_count: Int = 0
    
    var comments_count: Int = 0
    
    var attitudes_count: Int = 0
    
    
    
    init(dic:[String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dic)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            guard let v = value as? [String : AnyObject] else{
                
                return
            }
            user = ZCUser(dic: v)
        }else if key == "retweeted_status" {
            guard let ret = value as? [String : AnyObject] else {
                return
            }
            retweeted_status = ZCHomeModel(dic:ret)
        
        }else if key == "pic_urls" {
            guard let pic = value as? [[String : AnyObject]] else {
                return
            }
            
            var temp: [ZCPicturesModel] = [ZCPicturesModel]()
            for dic in pic {
                let model = ZCPicturesModel(dic: dic)
                temp.append(model)
            }
            pic_urls = temp;
            
        }else{
            super.setValue(value, forKey: key)
        }
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    }
    
}
